XML DOM Tutorial
==================
What is XML DOM?
-------------------
- XML = eXtensible Markup Language (stores/transports data)
- DOM = Document Object Model (tree structure where everything is an object)
- The XML DOM allows programs to dynamically read, modify, delete, or add data.
XML DOM Tree Structure:
-------------------------
Example XML:
.. code-block:: xml
Harry Potter
J.K. Rowling
Tree structure:
.. code-block:: text
Document
└── library
└── book (category="fiction")
├── title ("Harry Potter")
└── author ("J.K. Rowling")
Common DOM Methods:
---------------------
- getElementsByTagName(): returns elements by tag name
- getElementById(): returns element by ID
- getAttribute(): gets an attribute's value
- setAttribute(): sets an attribute's value
- appendChild(): adds a child node
- removeChild(): removes a child node
- createElement(): creates a new element
- createTextNode(): creates a text node
Sample Access (JavaScript):
----------------------------
.. code-block:: html
Why Learn XML DOM?
-------------------
- Easy XML file manipulation
- Important for web services, SOAP APIs, configuration files
- Supported in Java, Python, JavaScript, C#, etc.